package com.entities.projectteam.requestmapparser;

import com.core.utils.RequestParams;
import com.entities.user.servicelayer.UserListLayer;
import com.model.project.TeamMember;
import com.model.user.User;


public class TeamMemberMapParser {

	public static TeamMember fromMap ( RequestParams requestParams ) {

		if ( requestParams == null ) {
			return null;
		}


		Integer userId = requestParams.integerAtIndexForKey(0, "user");

		String name = requestParams.stringAtIndexForKey(0, "name");

		String description = requestParams.stringAtIndexForKey(0, "description");

		UserListLayer userListLayer = new UserListLayer();
		User user = (User) userListLayer.objectByUNID(userId, null, null);


		TeamMember template = null;
		template = new TeamMember();
		template.setName(name);
		template.setDescription(description);
		template.getTeamMemberCategory().setUser(user);

		return template;
	}
}
